package 购票Thread方法;

import java.util.ArrayList;
import java.util.List;

public class maipiao extends Thread{
    private List<Ticks> lists;
    private String name;//售票员

    public maipiao( String name,int count) {
        this.name = name;
        lists=new ArrayList<>();
        for (int i=0;i<count;i++){
            lists.add(new Ticks(i+1));
        }
    }

    @Override
    public void run() {
        while (lists.size()>0){
            Ticks t=lists.remove(0);
            System.out.println(name +"卖了"+t);
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }
}
